package com.itheima.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.entity.Banner;
import com.itheima.entity.Movies;
import com.itheima.result.Result;
import com.itheima.service.BannerService;
import com.itheima.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private IndexService indexService;

    @Autowired
    private BannerService bannerService;


    /**
     * 获取轮播图
     *
     * @return
     */
    @GetMapping("/findBannerList")
    public Result findBannerList() {
        PageInfo<Banner> categoryList = bannerService.findByPage(1, 5, null);
        return Result.success(categoryList);
    }

    /**
     * 根据分类和分类下面的电影列表
     *
     * @return
     */
    @GetMapping("/findMovieListMap")
    public Result findMovieListMap() {
        Map<String, List<Movies>> map = indexService.findMovieListMap();
        return Result.success(map);
    }
}
